<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title><%= title %></title>
    <link rel="stylesheet" href="/stylesheets/style.css" />
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
      integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu"
      crossorigin="anonymous"
    />
  </head>
  <body>
    <nav class="navbar navbar-default">
      <div class="row flex-center">
        <div class="col-xs-12 col-md-8">
          <p class="navbar-brand"><%= title %></p>
        </div>
        <div class="col-xs-6 col-md-4 text-right">
          <a id="addLink" href="/users/order/create" class="navbar-link">
            <button type="button" class="btn btn-primary">添加记录</button>
          </a>
        </div>
      </div>
    </nav>

    <% list.forEach(item => { %>
      <% if(item.type == 1) { %>
        <div class="panel panel-success">
      <% } else { %>
        <div class="panel panel-danger">
      <% } %>
      <div class="panel-heading"><%= item.createTime %></div>
      <div class="panel-body">
        <div class="row">
          <div class="col-md-6"><%= item.text %></div>
          <% if(item.type == 1) { %>
            <div class="col-md-2 text-success">收入</div>
          <% } else { %>
            <div class="col-md-2 text-danger">支出</div>
          <% } %>
          <div class="col-md-2"><%= item.moneyValue %> 元</div>
          <div class="col-md-2">
            <a href="/users/order/<%= item._id %>">
              <button>编辑</button>
            </a>
            <a href="/users/order/delete/<%= item._id %>">
              <button>删除</button>
            </a>
          </div>
        </div>
      </div>
    </div>
    <% }) %>

    <script>
      //   const btn = document.querySelector("#addLink");
      //   btn.addEventListener("click", () => {});
    </script>
  </body>
</html>
